package com.jvmoutofmemory.platform.pushutil.service;

import com.jvmoutofmemory.platform.pushutil.entity.PushJob;
import com.jvmoutofmemory.platform.pushutil.response.PushResponseParser;

import java.util.List;

/**
 * @author adam
 * @date 2022-06-02
 */
public interface PushService {

    /**
     * 根据ID删除一条推送记录
     * @param id
     * @return
     */
    int deleteById(Long id);

    /**
     * 查询N天前的，推送成功的数据
     * @param days
     * @return
     */
    List<Long> selectFinishData(int days);

    /**
     * 获取所有未推送的请求
     */
    List<PushJob> selectNotPushedPushJobList(int size);

    /**
     * 获取所有推送失败但未到达最大失败次数的请求
     */
    List<PushJob> selectFailedPushJobList(int size);

    /**
     * 执行推送
     */
    void push(PushJob pushJob) throws Exception;

    /**
     * 入库一条，等待定时推送
     * @param pushJob
     */
    void insertOne(PushJob pushJob);

    /**
     * 立即推送，不入库
     * @param pushJob
     * @throws Exception
     */
    void pushNow(PushJob pushJob) throws Exception;

    /**
     * 立即推送，不入库
     * @param pushJob
     */
    void pushNowQuietly(PushJob pushJob);

    /**
     * 尝试立即推送，推送成功则不入库， 推送失败则入库
     * @param pushJob
     */
    void pushOrSave(PushJob pushJob);

    PushResponseParser getResponseParser(String type);
}
